package com.lzw.service.impl.superAdmin;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.lzw.mapper.superAdmin.BillsManageMapper;
import com.lzw.pojo.Bills;
import com.lzw.service.superAdmin.BillsManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.List;

@Service
public class BillsManageServiceImpl implements BillsManageService {

    @Autowired
    private BillsManageMapper billsManageMapper;

    @Override
    public List<Bills> list(Integer pageNum, Integer pageSize, String medicine, LocalDate billDate) {
        PageHelper.startPage(pageNum,pageSize);
        List<Bills> list = billsManageMapper.list(medicine, billDate);
        Page<Bills> bills = (Page<Bills>) list;
        return bills;
    }

    @Override
    public void delete(List<Integer> ids) {
        billsManageMapper.delete(ids);
    }

    @Override
    public void add(Bills bills) {
        bills.setBillDate(LocalDate.now());
        billsManageMapper.add(bills);
    }

    @Override
    public void update(Bills bills) {
        billsManageMapper.update(bills);
    }
}
